<?php

use yii\helpers\Html;
use yii\helpers\Url;
use kartik\grid\GridView;

/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var yiike\credit\models\search\CreditRecordSearch $searchModel
 */
$this->title                   = $searchModel->getAliasModel(true);
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="giiant-crud credit-record-index">

    <?php //      echo $this->render('_search', ['model' =>$searchModel]);   ?>


    <?php \yii\widgets\Pjax::begin(['id' => 'pjax-main', 'enableReplaceState' => false, 'linkSelector' => '#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success' => 'function(){alert("yo")}']]) ?>

    <div class="panel">
        <div class="box-header ">
            <h3 class="box-title">列表</h3>
            <div class="box-tools pull-right">
                
                <?=
                \yii\bootstrap\ButtonDropdown::widget(
                        [
                            'id'          => 'giiant-relations',
                            'encodeLabel' => false,
                            'label'       => '<span class="fa fa-paperclip"></span> 关联',
                            'dropdown'    => [
                                'options'      => [
                                    'class' => 'dropdown-menu-right'
                                ],
                                'encodeLabels' => false,
                                'items'        => [ [
                                        'url'   => ['credit/index'],
                                        'label' => '<i class="fa fa-arrow-right">&nbsp;' . '帐户管理' . '</i>',
                                    ]]
                            ],
                            'options'     => [
                                'class' => 'btn-default btn-sm'
                            ]
                        ]
                );
                ?>                
            </div>
        </div>

        <div class="box-body">


            <div class=" ">
                <?=
                GridView::widget([
                    'layout'           => '{items}{summary}{pager}',
                    'dataProvider'     => $dataProvider,
                    'pager'            => [
                        'class'          => yii\widgets\LinkPager::className(),
                        'firstPageLabel' => 'First',
                        'lastPageLabel'  => 'Last'],
                    'filterModel'      => $searchModel,
                    'tableOptions'     => ['class' => 'table table-striped table-bordered table-hover'],
                    'headerRowOptions' => ['class' => 'x'],
                    'columns'          => [

                        [
                            'class'          => 'yii\grid\ActionColumn',
                            'buttonOptions'  => ['class' => 'btn btn-default btn-xs'],
                            'contentOptions' => ['nowrap' => 'nowrap']
                        ],
                        'sn',
                        [
                            'class'     => yii\grid\DataColumn::className(),
                            'attribute' => 'user_id',
                            'format'    => 'raw',
                            'value'     => function ($model) {
                                if ($rel = $model->getUser()->one()) {
                                    return Html::a($rel->user_id, ['credit/view', 'user_id' => $rel->user_id,], ['data-pjax' => 0]);
                                } else {
                                    return '';
                                }
                            },
                        ],
                        [
                            'class'     => yii\grid\DataColumn::className(),
                            'attribute' => 'payer_id',
                            'format'    => 'raw',
                            'value'     => function ($model) {
                                if ($rel = $model->getPayer()->one()) {
                                    return Html::a($rel->user_id, ['credit/view', 'user_id' => $rel->user_id,], ['data-pjax' => 0]);
                                } else {
                                    return '';
                                }
                            },
                        ],
                        'type',
                        'title',
                        'status',
                        'created_at',
                        'value1',
                        'value2',
                        'value3',
                        'blance1',
                        'blance2',
                        'blance3',
                        'payer_blance1',
                        'payer_blance2',
                        'payer_blance3',
                    ],
                ]);
                ?>
            </div>
        </div>
    </div>
</div>


<?php \yii\widgets\Pjax::end() ?>



